package com.lx.spring.jdbc.Action;

import com.lx.spring.jdbc.dao.AccountDao;
import com.lx.spring.jdbc.entity.Account;
import com.lx.spring.jdbc.vo.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

@RestController
public class Login {

    @Autowired
    AccountDao aDao;

    @RequestMapping("login")
    public Result login(HttpServletRequest req) {
        long id = Long.parseLong(req.getParameter("name"));
        String pwd = req.getParameter("pwd");
        Account login = aDao.login(id, pwd);
        System.out.println("login = " + login);
        return new Result(1, "登录成功", login);

    }
}
